<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class user_library
{
	public function __construct()
    {
        if (!isset($this->CI))
        {
            $this->CI =& get_instance();
        }
    }
	
	public function userinfo($user)
	{
		$data['mid'] = $user['member_id'] ;
		$data['fullname'] = $user['lb_full_name'] ;
		$data['birthday'] = $user['lb_birthday'] ;
		$data['gender'] = $user['nb_gender'] ;
		$data['avatar'] = $user['lb_image'] ;
		$data['username'] = $user['lb_user_login'] ;
		$data['email'] = $user['lb_email'] ;
		$data['town'] = $user['town_id'] ;
		$data['phone'] = $user['lb_phone'] ;
		$data['address'] = $user['lb_address'] ;
		$data['website'] = $user['lb_website'] ;
		$data['yahoo'] = $user['lb_yahoo'] ;
		$data['skype'] = $user['lb_skype'] ;
		$data['msn'] = $user['lb_msn'] ;
		$data['timezone'] = $user['timezoneoffset'] ;
		$data['mail_orther'] = $user['bl_mail_orther'] ;
		$data['mail_admin'] = $user['bl_mail_admin'] ;
		$data['dt_create'] = $user['dt_create'] ;
		$data['last_login'] = $user['dt_last_login'] ;
		
		return $data ;
	}
	
	/*public function set_avatar($avatar='')
	{
		return $data['avatar'] = $avatar ;
	}*/
	
	public function get_day_of_birthday($birthday='')
	{
		$arr = explode('/', $birthday) ;
		return $arr[0] ;
	}
	
	public function get_month_of_birthday($birthday='')
	{
		$arr = explode('/', $birthday) ;
		$arr[1] = isset($arr[1]) ? $arr[1] : 0 ;
		return $arr[1] ;
	}
	
	public function get_year_of_birthday($birthday='')
	{
		$arr = explode('/', $birthday) ;
		$arr[2] = isset($arr[2]) ? $arr[2] : 0 ;
		return $arr[2] ;
	}
	
	function get_user_by_id($member_id)
	{
		$this->CI->db->where('member_id',$member_id) ;
		$query = $this->CI->db->get('fm_member') ;
		return $query->row() ;
	}
}